import java.util.ArrayList;
import java.util.Scanner;

public class PrimeNumbers {
	
	private static ArrayList<Integer> primes = new ArrayList<Integer>();
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("Please enter any integer number: ");
		findPrimeNumbers(input.nextInt());
		System.out.println("Prime numbers which are smaller or equal to the inputted number are " + primes.toString());
	}
	
	
	
	private static void findPrimeNumbers(int n){
		for (int i = 2; i <= n; i++){
			int count = 0;
			for (int j = 2; j <= i; j++){
				if (i % j == 0){
					count++;
				}
			}
			if (count == 1){
				primes.add(i);
			}
		}
	}
}